using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using Dao;
namespace Doctors_WebForum
{
    public partial class AdminMasterPage : System.Web.UI.MasterPage
    {
        // Active menu tab with string view 
        public string GetSelected(string _view)
        {
            string view = "";
            if (Session["view"] != null)
                view = Session["view"].ToString();
            // set default active is tab Summary
            if (view == "")
                view = "Summary";
            string se = "";
            if (_view == view)
                se = "selected";
            return se;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // request parameter of string view 
            string view = Request["view"];
            if (Session["user"] == null)
            {
                Response.Redirect("Login.aspx", true);
            }
            else
            {
                User user = new User();
                user = Session["user"] as User;
                UserData userData = new UserData();
                user = userData.GetByName(user.UserName);
                if (user == null)
                {
                    Response.Redirect("Login.aspx", true);
                }
                else
                {
                    lblName.Text = user.UserName;
                    lblLastLogin.Text = user.LastLogin.ToString();
                }
            }

        }

        protected void lbSingOut_Click(object sender, EventArgs e)
        {
            FormsAuthentication.SignOut();
            HttpContext.Current.Session.Clear();
            HttpContext.Current.Session.Abandon();
            Response.Redirect("Login.aspx");
        }
    }
}
